﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ServicesSheet_OfficeSuppliesFinace : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            NewDataSet();

            MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
            master.HelpHref = "~/Help/ServicesSheet/办公品财务统计.htm";
            master.PageName = "办公品财务统计";
            master.PicUrl = "";
            master.IntiBar();
        }
    }

    public String GetYearMonth(string year, string month)
    {
        //string strMonth = this.DSelYearMonth1.SelectMonth;
        //string strYear = this.DSelYearMonth1.SelectYear;
        //string Ret = "";
        //if (strYear != "" && strYear != "0" && strYear != string.Empty) Ret = strYear + "年";
        //if (strMonth != "" && strMonth != string.Empty && strMonth != "0") Ret = Ret + strMonth + "月";
        //return Ret;
        if (year == "" && month == "")
            return "";
        else
            return year + "/" + month;
    }

    private void NewDataSet()
    {
        DataSet Tmp;
        //string Sql = "";

        string strDep = this.DepartmentDList1.SelectDepmanetId;
        string strYear = this.DSelYearMonth1.SelectYear;
        string strMonth = this.DSelYearMonth1.SelectMonth;
        string sql = "exec proc_OfficeByDepartment '" + strDep + "','" + strYear + "','" + strMonth + "'";
        Tmp = Srvtools.CliUtils.ExecuteSql("GLModule", "cmdRefValUse", sql, true, Srvtools.CliUtils.fCurrentProject);

        wgvMaster.DataSource = Tmp.Tables[0];
        wgvMaster.DataBind();

        Label lbl = (Label)this.wgvMaster.FooterRow.FindControl("Label2");
        lbl.Text = "总计:￥" + Tmp.Tables[0].Compute("Sum(countMoney)", "").ToString();
    }

    protected void wgvMaster_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        wgvMaster.PageIndex = e.NewPageIndex;
        NewDataSet();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        NewDataSet();
    }
}
